<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>手工护理提成设定管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		fieldset{
			width:100%;
		}
		.ui-field-contain fieldset div.ui-input-text{
			float:left;
			width:60%;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				rules:{
	                "fixed_money": "ifMoney",
	                "bonus_rate": {
	                 	"range":[0,100] 
	                 }
	            },
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			var type = '${type}';
			if(type != "1") {
				var bonus_type = ${storeBonusSettingCare.bonus_type};
				if(bonus_type == 0) {
					$("#type_radio_2").css('display', 'none');
		     		$("#type_radio_1").css('display', 'block');
				} else {
					$("#type_radio_1").css('display', 'none');
		     		$("#type_radio_2").css('display', 'block');
				}
	     		$('input:radio').click(function(){
	             	var id =  $(this).val();
	             	if(id == 0) {
	             		$("#bonus_rate").val('0');
	             		$("#fixed_money").val('0.0');
	             		$("#type_radio_2").css('display', 'none');
	             		$("#type_radio_1").css('display', 'block');
	             	} else {
	             		$("#bonus_rate").val('0');
	             		$("#fixed_money").val('0.0');
	             		$("#type_radio_1").css('display', 'none');
	             		$("#type_radio_2").css('display', 'block');
	             	}
	            });
			}
			addParentPageNo();
		});
		
		function addParentPageNo() {
			var pageNo = sessionStorage.parentPageNo;
			var id = '${storeBonusSettingCare.id}';
			$("#pageNo").val(pageNo);
			var href = "${ctx}/employee/storeBonusSettingCare/list?employeeId=${employee.id}&type=${type}&pageNo=" +pageNo + "&currentSelectId=" +id;
			$("#return").attr("href", href);
		}
	</script>
</head>
<body>
	<form:form id="inputForm" class="form-input" modelAttribute="storeBonusSettingCare" action="${ctx}/employee/storeBonusSettingCare/save" method="post">
		<form:hidden path="id"/>
		<input type="hidden" id="pageNo" name="pageNo" />
		<form:hidden path="card_type"/>
		<div class="icon-buttons">
			<a id="return" data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="">返回</a>
			<input type="submit" value="保 存" data-icon="check" data-iconpos="notext"  data-inline="true"/>
		</div>
		<tags:message content="${message}"/>
		<input id="storeCareId" name="storeCare.id" type="hidden" value="${storeBonusSettingCare.storeCare.id}"/>
		<c:if test="${type == 0 || type == 1}">
			<div data-role="fieldcontain">
				<label for="templateId">
					<c:if test="${type == 0 }">
						计次护理卡模板:
					</c:if>
					<c:if test="${type == 1}">
						时段护理卡模板:
					</c:if>
				</label>
				${cardName}
			</div>
			<div data-role="fieldcontain">
				<label for="storeCareId">护理项目:</label>
				${storeBonusSettingCare.storeCare.care_type == 0? storeBonusSettingCare.storeCare.care.name : storeBonusSettingCare.storeCare.storeSelfCare.name}
			</div>
		</c:if>
		<c:if test="${type == 2 || type == 3}">
			<div data-role="fieldcontain">
				<label for="storeCareId">护理项目:</label>
				${storeBonusSettingCare.storeCare.care_type == 0? storeBonusSettingCare.storeCare.care.name : storeBonusSettingCare.storeCare.storeSelfCare.name}
			</div>
		</c:if>
		<div data-role="fieldcontain">
			<c:if test="${type == 0 || type == 2 || type == 3}">
				<fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
					<legend>提成方式:</legend>
					<form:radiobuttons path="bonus_type" items="${fns:getDictMap('bonus_type')}"/>
				</fieldset>
			</c:if>
			<c:if test="${type == 1}">
				<form:hidden path="bonus_type"/>
				<fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
					<legend>提成方式:</legend>按固定金额提成
				</fieldset>
			</c:if>
		</div>
		<c:if test="${type == 0 || type == 2 || type == 3}">
			<div data-role="fieldcontain"  id="type_radio_1">
	   			<label for="bonus_rate">提成比例(%):</label>
	    		<input type="number" id="bonus_rate" value="${fns:changeDisCount(storeBonusSettingCare.bonus_rate)}" name="bonus_rate" class="required digits"/>
			</div>
		</c:if>
		<c:if test="${type == 1}">
			<form:hidden path="bonus_rate"/>
		</c:if>
		<div data-role="fieldcontain" id="type_radio_2">
			<label for="fixed_money">提成金额(元):</label>
			<form:input path="fixed_money" htmlEscape="false" class="required"/>
		</div>
	</form:form>
</body>
</html>
